
<style type="text/css">

/** 左侧样式 **/
.left_part { float: left; width: 380px; padding: 20px; height: 280px; text-align: left; }
.left_part h1 { color: #dd4b39; font-size: 23px; font-weight: normal;}
.left_part h2 { color: #222; font-size: 15px; font-weight: normal; }
.left_part p { margin: 0 auto; text-align: left; padding: 10px; margin-top: 20px; background-color: #f7f7f7; }
.left_part ul { margin: 0 auto; padding-left: 20px; padding-top: 20px; }
.left_part li { color: gray; line-height: 180%; }
.left_part li b { padding-right: 10px; font-size: 14px; color: #000; }

/** 右侧样式 **/
#main table { background-color: #f7f7f7; margin-left: 120; padding: 10px; padding-right: 50px; width: 430px; }
#main table a { font-size: 16px; background: rgb(235,235,235); }
#main table a:hover { background-color: #ddd; color: #000; }
#main label { float: right; background-color: transparent; padding-top: 5px; }

.error_Tip {background-color:#FFFF99; padding:2px;} 
</style>

<div id="main">

<%= form_for(@user, :url => {:action => 'profile'}) do |f| %>

	<h3>修改密码</h3>
	<% if(request['notice'] != nil) %>
	<span class="error_Tip">
		<%= case request['notice'] 
			when 'pass_error' then '当前密码验证失败' 
			when 'newpass_error' then '新密码格式有误：不能少于6个字符'
			when 'save_success' then '保存成功，请牢记您的密码'
			when 'save_failure' then '保存失败，请重新尝试'
		end %></span>
	<% end %>
	<table align="center">
	<tr>
		<th>用户名称：</th>
		<td><%= f.text_field :name, :class=>'w150', :value => @user.name, :readonly=>'readonly', :style=>'color:#ccc' %></td>
	</tr>
	<tr>
		<th>当前密码：</th>
		<td><%= f.password_field :pass, :class=>'w150' %>
		</td>
	</tr>
	<tr>
		<th>新的密码：</td>
		<td><%= f.password_field :pass1, :class=>'w150' %>
			<input type="text" id="pass2" class="w150" style="display:none;" />
			<label><input type="checkbox" id="cbxTextPass" /> 明文显示</label>
		</td>
	</tr>
	<tr>
		<td colspan="2" align="center" style="padding-left: 40px;"><br/>
			<%= f.submit '保存信息', :class=>'btn btn-primary btn-large' %> &nbsp;&nbsp;
			<a href="javascript:void(0);" id="btn_reset" class="btn-large">重新填写</a>
		<td>
	</tr>
	</table>
<% end %>

</div>

<script type="text/javascript">
$().ready(function(){
	var pass0 = $('#user_pass');
	var pass1 = $('#user_pass1');
	var pass2 = $('#pass2');

	pass1.blur(function(){
		pass2.val($(this).val());
	});

	pass2.blur(function(){
		pass1.val($(this).val());
	});

	$('#cbxTextPass').click(function(){
		if(this.checked) {
			pass1.hide();
			pass2.show();
		} else {
			pass1.show();
			pass2.hide();
		}
	});

	// 保存信息
	$(':submit[name="commit"]').click(function(){
		if(pass0.val() == null || pass0.val().length < 4) {
			alert('请正确输入当前密码');
			pass0.select();
			return false;
		}
		return true;
	});

	// 重新填写
	$('#btn_reset').click(function(){
		$('form').get(0).reset();
	});
});
</script>


